***************************************************
* Calculation of Bresnahan-Reiss Entry Thresholds *
***************************************************

qui{
	
	margins if cat_ucc==1, expression((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5'+ _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1])) atmeans
	matrix t_monopoly = r(b)*`1'
	matrix se_monopoly = r(V)
	matrix se_monopoly = sqrt(se_monopoly[1,1])*`1'

	margins if cat_ucc==2, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2) atmeans
	matrix t_duopoly = r(b)*`1'
	matrix se_duopoly = r(V)
	matrix se_duopoly = sqrt(se_duopoly[1,1])*`1'

	margins if cat_ucc==3, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3) atmeans
	matrix t_nfirms3 = r(b)*`1'
	matrix se_f3 = r(V)
	matrix se_f3 = sqrt(se_f3[1,1])*`1'

	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)/((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1]))) atmeans
	matrix t_2f_1f = t_duopoly[1,1]/t_monopoly[1,1]
	matrix se_t21 = r(V)
	matrix se_t21 = sqrt(se_t21[1,1])
	
	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3)/(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*`4' + _b[ucc_v:n_hospaffucc_geo]*`5' + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black  + _b[ucc_v:gte_highschool]*gte_highschool + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)) atmeans
	matrix t_3f_2f = t_nfirms3[1,1]/t_duopoly[1,1]
	matrix se_t32 = r(V)
	matrix se_t32 = sqrt(se_t32[1,1])

}

disp "UCC"
matrix list t_monopoly
matrix list se_monopoly
matrix list t_duopoly
matrix list se_duopoly
matrix list t_nfirms3
matrix list se_f3
matrix list t_2f_1f
matrix list se_t21
matrix list t_3f_2f
matrix list se_t32
